package hiatao.puzzle.activity;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.TextView;

import haitao.puzzle.R;
import hiatao.puzzle.utils.StatusBarCompat;
import hiatao.puzzle.utils.Tools;

public class SuggestActivity  extends Activity implements OnClickListener{

	private View top_back;
    private TextView commit_tv;
    private EditText suggest_et;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_suggest);
		findView();
		init();
		StatusBarCompat.compat(this, getResources().getColor(R.color.primary));
	}

	private void init() {
		top_back.setOnClickListener(this);
		commit_tv.setOnClickListener(this);
	}

	private void findView() {
        top_back =  findViewById(R.id.top_back);
        commit_tv = (TextView) findViewById(R.id.commit_tv);
        suggest_et = (EditText) findViewById(R.id.suggest_et);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {

		case R.id.top_back:
			finish();
			break;
		case R.id.commit_tv:
			commit();
			break;
		default:
			break;
		}
	}

	private void commit() {
		
		if(!TextUtils.isEmpty(suggest_et.getText())){

			Tools.showWaitDialog(this,"提交中", false);
			new Handler().postDelayed(new Runnable() {
				
				@Override
				public void run() {
					Tools.dismissWaitDialog();
					suggest_et.setText("");
					Tools.showToast("您的宝贵意见意见已经提交");
				}
			}, 1200);
		
		}else{
			Tools.showToast("请先填写意见");
		}
	}
	
}
